# 7.6.1
class Amphibian:
    name = "两栖动物"
    def features(self):
        print("幼年用鳃呼吸")
        print("成年用肺兼皮肤呼吸")
class Frog(Amphibian):            # Frog类继承自Amphibian类
    def attr(self):
        print("我会呱呱叫")
# 创建Frog类的对象
frog = Frog()
# 访问子类对象的属性与方法
print(frog.name)
frog.features()
frog.attr()

# 7.6.2
class English:
    def receive_eng_know(self):
        print('具备英语知识。')
class Math:
    def receive_math_know(self):
        print('具备数学知识。')
class Student(English, Math):
    def study(self):
        print('学生的任务是学习。')
stu = Student()
stu.receive_eng_know()
stu.receive_math_know()
stu.study()

# 7.6.3
# 方法重写示例
class Felines:
    def speciality(self):
        print("猫科动物善于奔跑")
class Cat(Felines):
    name = "猫"
    def speciality(self):
        print(f'{self.name}爱吃鱼')
        print(f'{self.name}会爬树')
# 调用重写后的方法
cat = Cat()
cat.speciality()


# 7.6.4
class Cat(Felines):
    name = "猫"
    def speciality(self):
        print(f'{self.name}爱吃鱼')
        print(f'{self.name}会爬树')
        print('-' * 20)
        super().speciality()  # 调用父类的speciality方法
# 再次调用方法
cat = Cat()
cat.speciality()


#7.8
class Animal(object):       # 定义父类Animal
    def move(self):
        pass
class Rabbit(Animal):      # 定义子类Rabbit
    def move(self):
        print("兔子蹦蹦跳跳")
class Snail(Animal):       # 定义子类Snail
    def move(self):
        print("蜗牛缓慢爬行")
def test(obj):             # 在函数test()中调用了对象的move()方法
    obj.move()
rabbit = Rabbit()
test(rabbit)
snail = Snail()
test(snail)